package com.example.micrweb.front.controller;

import com.example.micrweb.front.view.RespResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import org.example.api.model.User;
import org.example.api.pojo.BaseInfo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description: TODO
 * @author: uu
 * @data: 2023/7/11 下午 07:05
 * @version: v1.0
 */
@CrossOrigin
@Tag(name = "平台信息")
@RestController
@RequestMapping("/v1")
public class PlatInfoController extends BaseController {

    @Operation(summary = "平台基本信息", description = "注册人数、平局利率、总投资金额")
    /*平台基本信息*/
    @GetMapping("/plat/info")
    public RespResult queryPlatBaseInfo(){
        RespResult result = new RespResult();
        BaseInfo baseInfo = platBaseInfoService.queryPlatBaseInfo();
        result.setCode(1000);   // 表示成功
        result.setMsg("查询平台成功");
        result.setData(baseInfo);
        return result;
    }

    @Operation(summary = "所有用户的信息")
    @GetMapping("/user/info")
    public RespResult queryAllUser(){
        RespResult result = RespResult.success();
        List<User> users = platBaseInfoService.queryAllUserInfo();
        result.setData(users);
        return result;
    }

}
